package com.day9_Map_test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

/**
 * @ClassName: ArrayList_set_HashMap
 * @Author: zw
 * @Description: 出百万拳，行万里路；
 * @Create 2024/3/10-11:44
 * @Version 1.0
 */
public class ArrayList_set_HashMap {
    public static void main(String[] args) {
        // 创建arrayList集合
        ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String, String>>();

        // 创建hashMap集合1
        HashMap<String, String> hs1 = new HashMap<String, String>();
        hs1.put("郭靖", "黄蓉");
        hs1.put("杨过", "小龙女");

        // arraylist 添加 集合1
        arrayList.add(hs1);

        // create hashmap collection2
        HashMap<String, String> hs2 = new HashMap<String, String>();
        hs2.put("陈平安", "宁姚");
        hs2.put("六霸桥", "苏嫁");
        arrayList.add(hs2);

        HashMap<String, String> hs3 = new HashMap<String,String>();

        hs3.put("周瑜", "小乔");
        hs3.put("孙策", "大乔");
        arrayList.add(hs2);
        for (HashMap<String, String> hs : arrayList) {
            Set<String> hspre = hs.keySet();
            for (String key:hspre) {
               String value =  hs.get(key);
                System.out.println(key + "---" +value);
            }

        }
        for (int i = 0; i < arrayList.size(); i++) {
            Set<String> hspre = arrayList.get(i).keySet();
            for(String key : hspre) {
                String value = arrayList.get(i).get(key);
                System.out.println(key + "--" + value);
            }
            if (i != arrayList.size() -1) {
                System.out.println("-----");
            }
        }

    }
}
